# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=blisp
pkgver=0.0.3
pkgrel=1
pkgdesc='ISP tool & library for Bouffalo Labs RISC-V Microcontrollers and SoCs'
arch=(loong64 x86_64)
url=https://github.com/pine64/blisp
license=(MIT)
depends=(glibc)
makedepends=(
  cmake
  git
  ninja
)
_tag=5e09eca00d6fff8231441573b6a0ad129c6dcebe
options=(!debug)
source=(
  git+https://github.com/pine64/blisp.git#tag=${_tag}
  git+https://github.com/argtable/argtable3.git
  git+https://github.com/sigrokproject/libserialport.git
)
b2sums=('SKIP'
        'SKIP'
        'SKIP')

prepare() {
  cd blisp
  for submodule in vendor/{argtable3,libserialport}; do
    git submodule init ${submodule}
    git config submodule.${submodule}.url ../${submodule#*/}
    git -c protocol.file.allow=always submodule update ${submodule}
  done
}

pkgver() {
  cd blisp
  git describe --tags | sed 's/^v//'
}

build() {
  cmake -S blisp -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=None \
    -DBLISP_BUILD_CLI=ON \
    -Wno-dev
  cmake --build build
}

package() {
  install -Dm 755 build/tools/blisp/blisp -t "${pkgdir}"/usr/bin/
  install -Dm 644 blisp/LICENSE -t "${pkgdir}"/usr/share/licenses/blisp/
}

# vim: ts=2 sw=2 et:
